#ifndef AMINOACID_H
#define AMINOACID_H

#include <sstream>

namespace profo {

/**
 * A basic C++ class that holds information about each AminoAcid in some
 * Protein. Please note that this structure can be used in both triangular
 * and rectangular lattices.
 *
 * In the case of triangular lattices we use skewed axis coordinate system where
 * angle between X and Y axis is 60 degrees.
 *          +Y
 *         /
 * -X ----O---- +X
 *       /
 *     -Y
 * @see Protein
 */
struct AminoAcid {
  bool h; ///< false if hydrophobic (non-polar), true if hydrophillic (polar)
  int x; ///< X coordinate of the amino acid.
  int y; ///< Y coordinate of the amino acid.
  unsigned short id; ///< each amino acid has its own ID number.

  /**
   * A byte which tell us if there are surrounding free places around this
   * amino acid. Reasons why we hold this information in this structure are:
   * - this information is clearly related to it.
   * - it can be used in optimisation (so we do not iterate through the whole chain
   *   whenever we need to find free place to move some amino acid.
   * - finally, different algorithms may have different rules, and viewer cannot
   *   be aware of them.
   */
  unsigned char free;

  /**
   * Default constructor
   */
  AminoAcid(bool argH = false, int argX = 0, int argY = 0) {
    h = argH;
    x = argX;
    y = argY;
  } // AminoAcid constructor

  /// Copy constructor
  AminoAcid(const AminoAcid& arg) {
    h = arg.h;
    x = arg.x;
    y = arg.y;
  }

  /**
   * Convenience method to print the information about the AminoAcid object itself.
   * @return std::string A string object.
   */
  std::string toString() {
    std::ostringstream ret;
    ret << (h ? "H," : "P,");
    ret << x << "," << y << "," << id;
    return ret.str();
  } // toString() method

}; // AminoAcid class

/**
 * A class to hold information about a certain amino acid in both triangular and
 * rectangular 3D grids.
 * Same applies here in the case of the triangular grid.
 * @see Protein
 * @see AminoAcid
 */
struct AminoAcid3D: public AminoAcid {
  int z; ///< Z coordinate of the amino acid

  /// Default constructor
  AminoAcid3D(bool argH = false, int argX = 0, int argY = 0, int argZ = 0):
    AminoAcid(argH, argX, argY)
  {
    h = argH;
    x = argX;
    y = argY;
    z = argZ;
  } // AminoAcid3D constructor

  /// Copy constructor
  AminoAcid3D(const AminoAcid3D& arg): AminoAcid(arg.h, arg.x, arg.y) {
    h = arg.h;
    x = arg.x;
    y = arg.y;
    z = arg.z;
  } // AminoAcid3D constructor

  /**
   * Overloaded AminoAcid::toString(). Returns a string in the form "W,X,Y" where
   * W is either "H" or "P".
   */
  std::string toString() {
    std::ostringstream ret;
    ret << (h ? "H," : "P,");
    ret << x << "," << y << "," << z;
    return std::string(ret.str());
  } // toString() method
}; // AminoAcid3D structure

} // profo namespace

// $Id: AminoAcid.h 42 2009-04-26 04:31:13Z dejan.lekic $

#endif // AMINOACID_H
